package test.marui.com.mytest.view.slideBackView.view;

import android.app.Activity;
import android.support.annotation.NonNull;

import test.marui.com.mytest.utils.DisplayUtil;

/**
 * Created by MR on 2019/2/20.
 */
public class SlideBack {

    private ISlideView slideView;
    private int canSlideWidth;
    private OnSlide onSlide;

    public static SlideBack create() {
        return new SlideBack();
    }

    public SlideBack SlideView(ISlideView slideView) {
        this.slideView = slideView;
        return this;
    }

    public SlideBack canSlideWidth(int canSlideWidth) {
        this.canSlideWidth = canSlideWidth;
        return this;
    }

    public SlideBack onSlide(OnSlide onSlide) {
        this.onSlide = onSlide;
        return this;
    }

    public SlideControlLayout attachToActivity(@NonNull Activity activity) {

        if (canSlideWidth == 0) {
            canSlideWidth = DisplayUtil.dip2px(activity, 18);
        }

        if (slideView == null) {
            slideView = new DefaultSlideView(activity);
        }

        return new SlideControlLayout(activity, canSlideWidth, slideView, onSlide).attachToActivity(activity);
    }

}
